﻿using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using Kingdee.K3.FIN.GL.Business.PlugIn.BizVoucher;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WSDZ.KM.ZH.OtherReceivableGotoReport1
{
    [Description("【过滤框】应收款明细表"), HotUpdate]
   public class ReceivableDetailReportFilter: AbstractReportFilter
    {
        public override void TreeNodeClick(TreeNodeArgs e)
        {
            base.TreeNodeClick(e);
            if (this.View.ParentFormView.OpenParameter.GetCustomParameter("custType") != null && this.View.ParentFormView.OpenParameter.GetCustomParameter("custId") != null)
            {
                //DynamicObject orgObj = UtilityManager.GetDynamicObjectById(Context, "AR_DetailRepFilter", "FSettleOrgLst", 1);
                //this.View.Model.SetValue("FSettleOrgLst", orgObj);
                //this.View.UpdateView("FSettleOrgLst");

                //this.View.Model.SetValue("FBeginDate", DateTime.Now.AddYears(-1).ToString("yyyy-MM-dd"));
                //this.View.Model.SetValue("FEndDate", DateTime.Now.ToString("yyyy-MM-dd"));
                //this.View.UpdateView("FBeginDate");
                //this.View.UpdateView("FEndDate");

                //this.View.Model.SetValue("FOutSettle", true);
                //this.View.Model.SetValue("FInSettle", true);
                //this.View.UpdateView("FOutSettle");
                //this.View.UpdateView("FInSettle");

                var custType = this.View.ParentFormView.OpenParameter.GetCustomParameter("custType").ToStringV1();
                var custId = this.View.ParentFormView.OpenParameter.GetCustomParameter("custId").ToStringV1().ToInt32V1();
                this.View.Model.SetValue("FCONTACTUNITTYPE", custType);//对过滤窗口字段赋值
                this.View.UpdateView("FCONTACTUNITTYPE");
                DynamicObject custObj = UtilityManager.GetDynamicObjectById(Context, "AR_DetailRepFilter", "FCONTACTUNITFrom", custId);
                if (custObj != null)
                {
                    this.View.Model.SetValue("FCONTACTUNITFrom", custObj);
                    this.View.Model.SetValue("FCONTACTUNITTo", custObj);
                    this.View.UpdateView("FCONTACTUNITFrom");
                    this.View.UpdateView("FCONTACTUNITTo");
                }


                //((IDynamicFormViewService)this.View).ButtonClick("FBTNOK", string.Empty);//模拟过滤窗口确定按钮点击
            }
        }

        public override void ButtonClick(ButtonClickEventArgs e)
        {
            base.ButtonClick(e);
            if (e.Key.EqualsV1("FbtnABC"))
            {
               var obj= this.Model.GetValue("FCONTACTUNITFrom");
            }
        }

    }
}
